package com.example.boot.test.controller;

import com.example.boot.commen.cst.Const;
import com.example.boot.test.model.Account;
import com.example.boot.test.services.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author ruiwu
 * @version V1.0
 * @Description:
 */
@Controller
@RequestMapping(value = "/demo")
public class DemoController {

    @Autowired
    private DemoService demoService;

    @RequestMapping(value = "/testMybaties", method= RequestMethod.POST,produces = Const.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public String testMybaties(){
        List<Account> list = demoService.findAllAccount();
        System.out.println(list.get(0));
        return"success";
    }

    @RequestMapping(value = "/testTransactional", method= RequestMethod.POST,produces = Const.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public String testTransactional(){
       demoService.testTransactional();
        return"success";
    }

}
